<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>已分配记录</title>
    <c:import url="../../header.jsp"/>
</head>
<body>
<div class="content-warp">
    <div class="dgg-list-top-warp">
        <div class="screen-search">
            <ul>
                <li>
                    <label>客户姓名：</label>
                    <input type="text" class="dggui-input dggui-input-normal" id="customerName" name="customerName" placeholder="输入客户姓名" maxlength="50">
                </li>
                <li>
                    <label>分配时间：</label>
                    <input type="text" readonly class="dggui-input dggui-time-range" id="allotDate" name="allotDate">
                    <i class="iconfont icon-rili"></i>
                </li>
                <li>
                    <label>分配人员：</label>
                    <select  id="allotUserId" name="allotUserId">
                    </select>
                </li>
                <li>
                    <label>流程人员：</label>
                    <select  id="flowUserId" name="flowUserId">
                    </select>
                </li>
                <li>
                    <label>所属生产事业部：</label>
                    <select id="productOrgId" id="productOrgId" name="productOrgId" >
                    </select>
                </li>
                <li>
                    <label>签单商务：</label>
                    <select id="signUserId" name="signUserId" class="dggui-select">
                    </select>
                </li>
                <li>
                    <label>签单部门：</label>
                    <div class="tree-select-warp">
                        <input type="text" class="dggui-input input-selct-tree" id="signOrg" name="signOrg"  data-id="" value=""  style="width: 320px"  />
                    </div>
                </li>
              <%--  <li>
                    <label>业务类型：</label>
                    <div name="typeCode" id="typeCode"></div>
                </li>
                <li>
                    <label>产品：</label>
                    <select name="productCode" id="productCode" >
                    </select>
                </li>
                <li>
                    <label>渠道：</label>
                    <select name="channelCode" id="channelCode" class="dggui-select">
                        <option value=''>请选择</option>
                    </select>
                </li>--%>

                <li>
                    <label>关键字：</label>
                    <input type="text" class="dggui-input dggui-input-large" id="searchKey" name="searchKey" placeholder="订单编号/生产单编号/客户号码" maxlength="50" style="width: 190px;">
                </li>
              <%--  <li>
                    <label>需求金额：</label>
                    <input type="number" class="dggui-input dggui-input-large" id="moneyMin" name="moneyMin" placeholder="输入最小金额" min="0">~
                    <input type="number" class="dggui-input dggui-input-large" id="moneyMax" name="moneyMax" placeholder="输入最大金额" min="0">
                </li>--%>
                <li>
                    <button class="dggui-btn searchBtn" >搜索</button>
                    <button class="dggui-btn dggui-btn-primary" onclick="cleanSearch()">清空条件</button>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_EXPORT">
                    <button class="dggui-btn dggui-btn-green" onclick="excelExportAllotRecord()">导出</button>
                    </d:hasUrlAuth>
                </li>
            </ul>
        </div>
    </div>
    <div class="list-content">
        <div class="table-warp">
            <table class="dggui-table" id="allocateRecordTable">
            </table>
        </div>
    </div>

</div>

<c:import url="../../footer.jsp"/>
<script>
    var tables;
    var allocateRecord  = {
        "list":sysInfo.basePath+"/rzsc/allocate/allocate_record_list.do",//分页数据
        "allocatePage":sysInfo.basePath+ "/rzsc/allocate/allot_scorder_page.html"//审核页面
    }
    dggui.use(['table', 'select2','distpicker','dggdate','droptree'], function (){
        var timeout = $('#timeout').attr('data-timeout');
        var table = dggui.table;
        var select2 = dggui.select2;
        var distpicker=dggui.distpicker;
        var dggdate = dggui.dggdate;
        var droptree=dggui.droptree;
        //初始化所属生产事业部
        syb("#productOrgId");
        select2.render({
            placeholder: "请选择",
            elem: $('#productOrgId'),
            allowClear: true,
            width: "160px"
        });
        //
        // select2.render({
        //     placeholder: "请选择",
        //     allowClear: true,
        //     elem: $('#productCode'),
        //     width: "160px"
        // });

        <%--//初始化业务类型及产品--%>
        <%--var codeName = '${codeName}';--%>
        <%--var titles = '选择业态';--%>
        <%--if(!isEmpty(codeName)){--%>
            <%--titles = codeName;--%>
            <%--//初始化产品--%>
            <%--initProductCode("#productCode",'${code}');--%>
            <%--select2.render({--%>
                <%--placeholder: "请选择",--%>
                <%--allowClear: true,--%>
                <%--elem: $('#productCode'),--%>
                <%--width: "160px"--%>
            <%--});--%>
        <%--}--%>
        <%--distpicker.render({--%>
            <%--url: "${basePath}/rzsc/common/tree_book_list.do?code=BUS_YT_DK&type=2&level=2", // 请求地址--%>
            <%--elem: '#typeCode', // 容器Id--%>
            <%--type: 2,--%>
            <%--placeholder: titles,--%>
            <%--defaultParentCode:'BUS_YT_DK',--%>
            <%--callback:function () {//如果不需要选产品就把callback整个方法注释掉--%>
                <%--var code = $("#typeCode .plug-in-code").val();--%>
                <%--initProductCode("#productCode",code);--%>
                <%--select2.render({--%>
                    <%--placeholder: "请选择",--%>
                    <%--allowClear: true,--%>
                    <%--elem: $('#productCode'),--%>
                    <%--width: "160px"--%>
                <%--});--%>
                <%--var produtId = $("#productCode").val();--%>
                <%--initChannel("#channelCode",produtId);--%>
                <%--select2.render({--%>
                    <%--placeholder: "请选择",--%>
                    <%--allowClear: true,--%>
                    <%--elem: $('#channelCode'),--%>
                    <%--width: "160px"--%>
                <%--});--%>
            <%--},--%>
            <%--callbackClear:function () {--%>
                <%--$("#productCode").find("option").remove();--%>
                <%--$("#productCode").append("<option value=''>请选择</option>");--%>
                <%--$("#channelCode").find("option").remove();--%>
                <%--$("#channelCode").append("<option value=''>请选择</option>");--%>
            <%--}--%>
        <%--});--%>
        <%--if(!isEmpty(codeName)){--%>
            <%--$("#typeCode .plug-in-code").val('${code}');--%>
        <%--}--%>
        <%--//渠道初始化--%>
        <%--$('#productCode').on('change', function (e) {--%>
            <%--var produtId = $("#productCode").val();--%>
            <%--initChannel("#channelCode",produtId);--%>
            <%--select2.render({--%>
                <%--placeholder: "请选择",--%>
                <%--allowClear: true,--%>
                <%--elem: $('#channelCode'),--%>
                <%--width: "160px"--%>
            <%--});--%>
        <%--});--%>
        //初始化签单商务
        initUser("bus_advisor", "role", "#signUserId");
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#signUserId'),
            width: "160px"
        });

        //初始化流程人员
        initUser("RZSC_FLOW_USER","role","#flowUserId");
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#flowUserId'),
            width: "160px"
        });
        //初始化分配人员
        initUser("RZSC_ALLOT_USER","role","#allotUserId");
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#allotUserId'),
            width: "160px"
        });
        //初始化分配时间
        var timeType = '${timeType}';
        if(!isEmpty(timeType)){
            $("#allotDate").val(timeType);
        }
        dggdate.render({
            elem: '#allotDate',
            type: 'date',
            range: '~',
            value: timeType,
            isInitValue: true
        });


        // 加载部门下拉框
        queryAllDep("#signOrg");

        var opt={
            "elem":"#allocateRecordTable",
            "ajax": allocateRecord.list,
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 4,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "fnServerParams": function (aoData) {
             /*   var moneyMax = $("#moneyMax").val().trim();
                var moneyMin = $("#moneyMin").val().trim();*/
                //搜索条件
                aoData = $.extend(aoData, {
                    // customerPhone: $("#customerPhone").val(),
                    productOrgId: $("#productOrgId").val(),
                    // typeCode: $("#typeCode").find(".plug-in-code").val(),
                    // productId: $("#productCode").val(),
                    // channelId:$("#channelCode").val(),
                    allotDate: $("#allotDate").val(),
                    flowUserId:$("#flowUserId").val(),
                    allotUserId:$("#allotUserId").val(),
                    searchKey: $("#searchKey").val(),
                    customerName:$("#customerName").val(),
                    signUserId:$("#signUserId").val(),
                    signOrgOrBusId:$("#signOrg").attr("data-id"),
                /*    moneyMax:moneyMax,
                    moneyMin:moneyMin,*/
                    }
                )
                return aoData;
            },
            "aoColumns": [{
                "sClass": "check-th",
                "title": "<input type='checkbox'  class='checkall'>",
                "orderable": false,
                "render": function(data, type, full, meta) {
                    return '<input type="checkbox" class="checkchild" name="checkchild" value="' + data + '">';
                }
            }, {
                'title': '序号',
                "orderable": false,
                "render": function(data, type, full, meta) {
                    return meta.row + 1;
                }
            },
                {
                    'title': '所属生产事业部',
                    'data': "productOrgName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render"><b>'+data ? data : ''+'<b></div>';
                        return htm;
                    }
                },
                {
                    "title": "订单编号",
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        return ('<a href="javascript:;" class="dggui-link"  onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><span>' + data + '</span></a>');
                        /*return data;*/
                    }
                },
                {
                    'title': '生产订单编号',
                    'data': "scProductOrderNo",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<a href="javascript:void(0)" class="dggui-link" onclick="openOrderInfoDetail(\''+data+'\',\''+row.id+'\')">'+data+'</a>';
                        return htm;
                    }
                }, {
                    'title': '客户',
                    'data': "customerName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                            '<p><span>' +emptyStringConvert(row.customerName) + '</span></p>' +
                            '<p>' + emptyStringConvert(row.customerPhone) + '</p>' +
                            '</div>'
                        return htm;
                    }
                },  {
                    'title': '业务类型',
                    'data': "businessProductName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                        '<p class="line1" title="'+data ? data : ''+'"><span >' +data ? data : '' + '</span></p>'+
                            '</div>'
                        return htm;
                    }
                },
                {
                    'title': '产品',
                    'data': "productName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                        '<p class="line1" title="'+data+'"><span >' +data ? data : '' + '</span></p>'+
                            '</div>'
                        return htm;
                    }
                },
                {
                    'title': '建议渠道',
                    'data': "channelName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                        '<p class="line1" title="'+data+'"><span >' +data ? data : '' + '</span></p>'+
                            '</div>'
                        return htm;
                    }
                },
                {
                    'title': '分配时间',
                    'data': "allotDate",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm =  '<div class="order-render"><p>' + data ? data : '' + '</p></div>';
                        return htm;
                    }
                },
                {
                    'title': '分配人',
                    'data': "allotUserName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                        '<p class="line1" title="'+data+'"><span >' +data ? data : '' + '</span></p>'+
                            '</div>'
                        return htm;
                    }
                },
                {
                    "title":"签单时间",
                    "orderable": false,
                    "data": "orderTime",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"签单商务/部门",
                    "orderable": false,
                    "data": "signUserName",
                    "render": function (data, type, full, meta) {
                        return emptyStringConvert(full.signUserName) + '<p>' + emptyStringConvert(full.signUserOrgName) + '</p>';
                    }
                },
                {
                    'title': '流程人员',
                    'data': "flowUserName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        return data ? data+'<p>'+emptyStringConvert(row.flowUserOrgName)+'</p>': '';
                    }
                },/*{
                    'title': '流程部门',
                    'data': "flowUserOrgName",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                        '<p><span >' +data ? data : '' + '</span></p>'+
                            '</div>'
                        return htm;
                    }
                },*/
                {
                    'title': '需求金额（元）',
                    'data': "loanAmount",
                    "orderable": false,
                    "render": function(data, type, row, meta) {
                        var htm = '<div class="order-render">' +
                        '<p><span >' +data ? data : '' + '</span></p>'+
                            '</div>'
                        return htm;
                    }
                },
                {
                    'title': '最新备注',
                    'data': "lastRemark",
                    "orderable": false,
                    "render": function (data, type, row, meta) {
                        return '<div class="line1" title="'+data+'"><p>' + strInterception(data,10) + '</p></div>' + '<p>'+emptyStringConvert(row.lastRemarkTime)+'</p>';
                    }
                }

            ],
            "columnDefs": [{
                targets: [3], //第1，2，3列
                createdCell: function (td, cellData, rowData, row, col) {

                }
            }]
        };
        tables=table.render(opt);
        $('.searchBtn').click(function (){
         /*   var moneyMax = $("#moneyMax").val().trim();
            var moneyMin = $("#moneyMin").val().trim();
            if(!checkMoneySearch(moneyMin,moneyMax)){
                return false;
            }*/
            tables.ajax.reload();
        });

        // 处理dataTable 异常错误信息
        $.fn.dataTable.ext.errMode = 'none';//不抛出异常
        tables.on( 'error.dt', function ( e, settings, techNote, message ) {
            //dggui.dialog.errors("表格查询错误，请联系管理员", 2000);
           if(checkEmpty(settings.jqXHR.responseJSON.error)){dggui.dialog.errors(settings.jqXHR.responseJSON.error, 2000);}
        });




    });

    function excelExportAllotRecord() {
     /*   var moneyMax = $("#moneyMax").val().trim();
        var moneyMin = $("#moneyMin").val().trim();
        if(!checkMoneySearch(moneyMin,moneyMax)){
            return;
        }*/
        var obj = new Object();
        // obj.customerPhone= $("#customerPhone").val();
        obj.productOrgId= $("#productOrgId").val();
        // obj.typeCode=$("#typeCode").find(".plug-in-code").val();
        // obj.productId= $("#productCode").val();
        // obj.channelId=$("#channelCode").val();
        obj.allotDate= $("#allotDate").val();
        obj.flowUserId=$("#flowUserId").val();
        obj.allotUserId=$("#allotUserId").val();
        obj.searchKey=$("#searchKey").val();
        obj.customerName = $("#customerName").val();
        // obj.moneyMax=moneyMax;
        // obj.moneyMin=moneyMin;
        formSubmit('${basePath}/rzsc/allocate/excel_export_wait_allot_record.do', obj);
    };

</script>
</body>
</html>